package com.lzx.applib.utils;

import android.net.Uri;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 16/12/24.
 */

public class UrlUtil {

    private static final String TAG = "UrlUtil";

    public static Map<String, String> getQueryMap(String url) {
        Map<String, String> queryMap = new HashMap<>();
        try {
            Uri uri = Uri.parse(url);
            String query = uri.getQuery();
            String[] datas = query.split("&");
            for (String data : datas) {
                if (data.contains("=")) {
                    String[] keyValue = data.split("=");
                    if (keyValue.length == 2) {
                        queryMap.put(keyValue[0], keyValue[1]);
                    }
                }
            }
        } catch (Exception e) {
            LogUtil.d(TAG, "getQueryMap error");
            e.printStackTrace();
        }
        return queryMap;
    }

}
